package com.java.control.impl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;

import com.java.control.AbstractAdminCommandController;
import com.java.control.search.ProductSearchCond;
import com.java.control.search.SearchStat;
import com.java.entity.Product;
import com.java.service.ProductService;

/**
 * 人员管理
 * @author wqf
 * @version  Nov 24, 2011 12:00:53 PM
 */
public class ProductListController extends AbstractAdminCommandController {

	public ProductListController(){
		this.setCommandClass(ProductSearchCond.class);
	}	

	protected ModelAndView executeRequest(HttpServletRequest request,HttpServletResponse response,Object command)
		throws Exception{
		
		ProductSearchCond searchCond = (ProductSearchCond)command;
		
		ModelAndView mav=new ModelAndView(this.view);
		searchCond.setPageSize(200L);
		SearchStat searchStat = this.productService.getSearchStat(Product.class, searchCond);
		List<Product> list = this.productService.search(Product.class,searchCond);
		mav.addObject("searchStat", searchStat);
		mav.addObject("searchCond", searchCond);
		mav.addObject("productList", list);		
		
		return mav;
		
	}
		
	public void setProductService(ProductService productService) {
		this.productService = productService;
	}

	private String view;
	private ProductService productService;
	
	public void setView(String view) {
		this.view = view;
	}

}
